home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Hacks
/
Hacks ’92
/
Clicks, not! ƒ
/
Clicks, not!.a
< prev
Wrap
Text File
|
1992-06-18
|
4KB
|
156 lines
;---------------------------------------------------------------------------------
;
; File: Clicks, not!.a
;
; Contains: A hack to find the SndWatch VBL in the queue which turns the
; ASC on and off on the PowerBooks. This makes a clicking noise
; and we hate that, so we remove the VBL task entirely.
;
; Written by: Jim Reekes
;
; Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
;
; Notes:
;
;---------------------------------------------------------------------------------
include 'SysEqu.a'
include 'SysErr.a'
include 'ToolEqu.a'
include 'Traps.a'
;---------------------------------------------------------------------------------
; equates
;---------------------------------------------------------------------------------
true equ 1
false equ 0
SndWFreq equ 60*10 ;Sound watch VBL is called very 10 seconds
SwVBLTask equ $90
soundRead equ $98 ;Power Manager parameter block - Sound power state
DEBUG equ true
;---------------------------------------------------------------------------------
; macros
;---------------------------------------------------------------------------------
;debugging symbol placed into the code for Macsbug to show us the routine name
macro
DbgInfo &routineName=&SysMod,&size=0
lclc &name, &oldString
IF DEBUG THEN
if &routineName[1:1] = '''' then
&name: setc &eval(&routineName)
else
&name: setc &routineName
endif
&oldString: setc &setting('string')
rts ;need a fake rts for MacsBug
string asis
if &len(&name) < 32 then
dc.b &len(&name)+$80,'&name'
else
dc.b $80,&len(&name),'&name'
endif
string &oldString
align
dc.w &size
endif
endm
;---------------------------------------------------------------------------------
; The main entry point.
;---------------------------------------------------------------------------------
StartINIT MAIN
jsr DoVBLKiller
rts ;bye bye
DbgInfo StartINIT ;this name will appear in the debugger
;---------------------------------------------------------------------------------
; Target code we're looking for in the VBL task
; This is the source code that appears inside of the Power Manager that
; I want to find and destroy.
;---------------------------------------------------------------------------------
StartTargetCode equ * ;marker to calculate the size of this code
SndWatch MOVE.L PmgrBase,A2
LEA SwVBLTask(A2),A0
MOVE.W #SndWFreq,vblCount(A0)
SUB.W #4,SP
MOVE.L SP,A0
MOVE.W #SoundRead,D0
BytesOfTargetCode equ *-StartTargetCode ;size of the target code
DbgInfo SndWatch ;this name will appear in the debugger
;---------------------------------------------------------------------------------
; Find the bogus SndWatch VBL in the queue and remove it
;---------------------------------------------------------------------------------
SaveKillerRegs reg d0/a0-a2 ;those that we will use we preserve
DoVBLKiller
movem.l SaveKillerRegs,-(sp)
move.l VBLQueue+qHead,a0 ;point into the VBL queue
;We want to confirm that this is the right routine that needs modified.
;This is done with a small loop. The C code below shows the idea.
;for (count = (BytesOfTargetCode/2)-1;count >= 0;--count)
; {
; if (sourceWordPtr++ == destWordPtr++)
; codeMatches = true;
; else
; codeMatches = false;
; }
;if (codeMatches)
; RemoveVBL();
NextVBL
move.l vblAddr(a0),a1
lea StartTargetCode,a2 ;point to are test code
move.w #(BytesOfTargetCode/2)-1,d0 ;count is DIV 2 for number of words
CompareLoop
;a1 points at the original code in the VBL task
;a2 points at our test code for comparing against
;d0 is the loop counter, in the number of words to compare
cmp.w (a1)+,(a2)+
dbne d0,CompareLoop
beq.s FoundVBL
move.l vblink(a0),a0
cmp.l #0,a0
beq.s ExitKiller ;no more VBLs in the queue
bra.s NextVBL
FoundVBL _VRemove
ExitKiller
movem.l (sp)+,SaveKillerRegs
rts
DbgInfo DoVBLKiller ;this name will appear in the debugger
end ;of source file